Use MVC 5 Scaffolding > Step 2 of 5: Add a Model |
Create a POCO (Plain Old CLR Objects) model for TahDoList and TahDoItem.
Visual Basic
Visual Basic |
Copy Code
|
---|---|
Imports using System.ComponentModel.DataAnnotations |
C#
C# |
Copy Code
|
---|---|
using System.ComponentModel.DataAnnotations; |
Visual Basic
Visual Basic |
Copy Code
|
---|---|
Public Class TahDoList <Editable(False)> _ Public Property Id() As Integer Get Return m_Id End Get Set m_Id = Value End Set End Property Private m_Id As Integer <Required> _ Public Property Title() As String Get Return m_Title End Get Set m_Title = Value End Set End Property Private m_Title As String <Display(Name := "Date Created")> _ Public Property CreatedAt() As System.Nullable(Of DateTime) Get Return m_CreatedAt End Get Set m_CreatedAt = Value End Set End Property Private m_CreatedAt As System.Nullable(Of DateTime) <Range(0, 5), UIHint("IntSlider")> _ Public Property Priority() As Integer Get Return m_Priority End Get Set m_Priority = Value End Set End Property Private m_Priority As Integer <Range(0, 1000000)> _ Public Property Cost() As Decimal Get Return m_Cost End Get Set m_Cost = Value End Set End Property Private m_Cost As Decimal <DataType(DataType.MultilineText)> _ Public Property Summary() As String Get Return m_Summary End Get Set m_Summary = Value End Set End Property Private m_Summary As String Public Property Done() As Boolean Get Return m_Done End Get Set m_Done = Value End Set End Property Private m_Done As Boolean <Display(Name := "Date Completed")> _ Public Property DoneAt() As System.Nullable(Of DateTime) Get Return m_DoneAt End Get Set m_DoneAt = Value End Set End Property Private m_DoneAt As System.Nullable(Of DateTime) Public Property TahDoItems() As ICollection(Of TahDoItem) Get Return m_TahDoItems End Get Set m_TahDoItems = Value End Set End Property Private m_TahDoItems As ICollection(Of TahDoItem) End Class Public Class TahDoItem <Editable(False)> _ Public Property Id() As Integer Get Return m_Id End Get Set m_Id = Value End Set End Property Private m_Id As Integer <Required> _ Public Property Title() As String Get Return m_Title End Get Set m_Title = Value End Set End Property Private m_Title As String <Display(Name := "Date Created")> _ Public Property CreatedAt() As System.Nullable(Of DateTime) Get Return m_CreatedAt End Get Set m_CreatedAt = Value End Set End Property Private m_CreatedAt As System.Nullable(Of DateTime) <Range(0, 5), UIHint("IntSlider")> _ Public Property Priority() As Integer Get Return m_Priority End Get Set m_Priority = Value End Set End Property Private m_Priority As Integer <DataType(DataType.MultilineText)> _ Public Property Note() As String Get Return m_Note End Get Set m_Note = Value End Set End Property Private m_Note As String Public Property TahDoListId() As Integer Get Return m_TahDoListId End Get Set m_TahDoListId = Value End Set End Property Private m_TahDoListId As Integer Public Property TahDoList() As TahDoList Get Return m_TahDoList End Get Set m_TahDoList = Value End Set End Property Private m_TahDoList As TahDoList Public Property Done() As Boolean Get Return m_Done End Get Set m_Done = Value End Set End Property Private m_Done As Boolean <Display(Name := "Date Completed")> _ Public Property DoneAt() As System.Nullable(Of DateTime) Get Return m_DoneAt End Get Set m_DoneAt = Value End Set End Property Private m_DoneAt As System.Nullable(Of DateTime) End Class |
C#
C# |
Copy Code
|
---|---|
public class TahDoList { [Editable(false)] public int Id { get; set; } [Required] public string Title { get; set; } [Display(Name = "Date Created")] public DateTime? CreatedAt { get; set; } [Range(0, 5), UIHint("IntSlider")] public int Priority { get; set; } [Range(0, 1000000)] public decimal Cost { get; set; } [DataType(DataType.MultilineText)] public string Summary { get; set; } public bool Done { get; set; } [Display(Name = "Date Completed")] public DateTime? DoneAt { get; set; } public ICollection<TahDoItem> TahDoItems { get; set; } } public class TahDoItem { [Editable(false)] public int Id { get; set; } [Required] public string Title { get; set; } [Display(Name = "Date Created")] public DateTime? CreatedAt { get; set; } [Range(0, 5), UIHint("IntSlider")] public int Priority { get; set; } [DataType(DataType.MultilineText)] public string Note { get; set; } public int TahDoListId { get; set; } public TahDoList TahDoList { get; set; } public bool Done { get; set; } [Display(Name = "Date Completed")] public DateTime? DoneAt { get; set; } } |
In the next step, you'll add a reference to the Entity Framework.